package com.zhihu_lvliangi_android.option.zhengwu.adapter;

import java.io.File;
import java.io.IOException;
import java.util.List;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.lidroid.xutils.BitmapUtils;
import com.lidroid.xutils.bitmap.BitmapDisplayConfig;
import com.lidroid.xutils.bitmap.core.BitmapSize;
import com.zhihu_lvliangi_android.R;
import com.zhihu_lvliangi_android.domain.NewItem;
import com.zhihu_lvliangi_android.domain.PlanModel;
import com.zhihu_lvliangi_android.option.HomePageActivity;
import com.zhihu_lvliangi_android.service.MobileApplication;
import com.zhihu_lvliangi_android.util.RequestURL;
import com.zhihu_lvliangi_android.util.ViewHolder;

/**
 * 新闻列表适配器
 * 
 * @author azuryleaves
 * @since 2014-3-13 下午5:23:24
 * @version 1.0
 * 
 */
public class ProgressListViewAdapter extends BaseAdapter {

	private List<PlanModel> data;
	private LayoutInflater inflater;
	private BitmapUtils bitmapUtil;
	private Context mContext;
	private BitmapDisplayConfig mDisplayConfig;

	public ProgressListViewAdapter(Context context, List<PlanModel> data) {
		super();
		mContext = context;

		inflater = LayoutInflater.from(context);
		bitmapUtil = new BitmapUtils(context);
		this.data = data;
		mDisplayConfig = MobileApplication.getInstance().initBitMapConfig(R.drawable.rotate_loading_360, R.drawable.rotate_loading_360);
	}

	@SuppressLint("ResourceAsColor")
	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {

		if (convertView == null) {
			convertView = inflater.inflate(R.layout.black_list_item,null );
		}
		PlanModel item = data.get(position);
		TextView tagView = ViewHolder.get(convertView, R.id.txt_num);
		tagView.setText(item.getId()+"");
		TextView titleView = ViewHolder.get(convertView, R.id.txt_name);
		titleView.setText(item.getName());
		TextView picktimeView = ViewHolder.get(convertView, R.id.txt_date);
		picktimeView.setText(item.getDeclarationdate());

		if (position %2 == 1) {
			convertView.setBackgroundResource(R.color.white);
		}
		return convertView;
	}


	@Override
	public int getCount() {
		return data.size();
	}

	@Override
	public Object getItem(int position) {
		return data.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

}
